﻿@model PresentationMVC.Models.InvoiceDataModel
<div class="success-msg">
    @ViewData["DELETE_MSG"]</div>
@{
    
    var grid = new WebGrid(Model.AllInvoice,
                                           defaultSort: "ID",
                                           rowsPerPage: 7, fieldNamePrefix: "",
                                           canPage: true, canSort: true,
                                           pageFieldName: "page", sortFieldName: "srt"
                                           );

}
<table cellpadding="0" cellspacing="0" width="100%">
    <tr>
        <td>
            @grid.Table(tableStyle: "listing-border", headerStyle: "gridhead", footerStyle: "paging", rowStyle: "td-dark", alternatingRowStyle: "td-light",
                                columns:
                                    grid.Columns(
                                             grid.Column("InvoiceNo", "Invoice No", style: "colInvoiceNo"),
                                             grid.Column("TotalAmount", "Total Amount", style: "colTotalAmount"),
                                             grid.Column("CreatedDate", "Created Date", style: "colCreatedDate"),
                                             grid.Column("Status.Type", "Payment Status", style: "colTitle"),
                                             grid.Column(header: "View", format: @<text><a href="@Url.Action("ViewInvoice", "Invoice", new { id = item.id })" >View</a></text>, style: "colOperation"),
                                             grid.Column(header: "Edit", format: @<text><a href="@Url.Action("EditInvoice", "Invoice", new { id = item.id })" >Edit</a></text>, style: "colOperation"),
                                             grid.Column(header: "Print", format: @<text><a href="@Url.Action("PrintInvoice", "Invoice", new { id = item.id })" >Print</a></text>, style: "colOperation"),
                                             grid.Column(header: "Payment", format: @<text>@LocalHelpers.PaymentLink(Url, item)</text>, style: "colOperation"),
                                             grid.Column(header: "Delete", format: @<text>@Ajax.ActionLink("Delete", "Delete", new { id = item.id, Page = grid.PageIndex + 1 }, new AjaxOptions
                                            {
                                                UpdateTargetId = "DivGrid",
                                                InsertionMode = InsertionMode.Replace,
                                                OnBegin = "return ConfirmDelete();",
                                                LoadingElementId = "resultLoadingDiv"
                                            })</text>, style: "colOperation")))
        </td>
    </tr>
</table>
@LocalHelpers.DoAjaxPager(Ajax,new AjaxOptions
{
    UpdateTargetId = "DivGrid",
    InsertionMode = InsertionMode.Replace,
    LoadingElementId = "resultLoadingDiv"
}, Html, "ReloadGrid", grid, 10, new { CurrentFilter = ViewBag.CurrentFilter })

<script type="text/javascript">
    function ConfirmDelete() {
        return confirm("Are you sure you want to delete this invoice?");
    }
</script>
